﻿using System;
class FirsBiggerThanNeighb
{
    static int InputNumber()
    {
        while (true)
        {
            try
            {
                int number = int.Parse(Console.ReadLine());
                return number;
            }
            catch (Exception)
            {
                Console.Write("Please re-enter number: ");
            }
        }
    }
    static int FirstBiggerThanNeighbors(int[] array)
    {
            for (int i = 1; i < (array.Length-1); i++)
            {
                if ((array[i] > array[i - 1]) && (array[i] > array[i + 1]))
                {
                    return i;
                }
            }          
        return -1;
    }
    static void Main()
    {
        int lenght = 0;
        int result;
        Console.Write("please enter the lenght of arrays: ");
        lenght = InputNumber();
        int[] theArray = new int[lenght];
        for (int i = 0; i < lenght; i++)
        {
            Console.Write("Please enter the {0} element of the array: ", i);
            theArray[i] = InputNumber();
        }
        result = FirstBiggerThanNeighbors(theArray);
        if (result != -1)
        {
            Console.WriteLine("the first number bigger than neighbors, is {0} at position [{1}]", theArray[result], result);
        }
        else
        {
            Console.WriteLine("there is no such element, bigger than neighbors");
        }
        Console.ReadLine();
    }
}

